package com.autonavi.yunda.yunji.core.model.dto;

import com.autonavi.yunda.yunji.core.enums.EngineType;
import com.autonavi.yunda.yunji.core.enums.InterfaceBuildType;
import com.autonavi.yunda.yunji.core.enums.InterfaceStatus;
import com.autonavi.yunda.yunji.core.enums.Method;
import com.autonavi.yunda.yunji.core.model.vo.InterfaceData;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.sql.Timestamp;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TableName(value = "yunji_interface_config", autoResultMap = true)
public class InterfaceConfigDTO {
    @TableId(type = IdType.AUTO)
    private Long id;
    private String name;
    private String description;
    private String uri;
    private Method method;
    private String version;
    @TableField("project_id")
    private String projectId;
    @TableField(value = "engine_data", condition = SqlCondition.LIKE)
    private String engineData;
    @TableField(value = "extra_data", condition = SqlCondition.LIKE)
    private String extraData;
    @TableField(value = "interface_data", typeHandler = JacksonTypeHandler.class)
    private InterfaceData interfaceData;
    private InterfaceStatus status;
    @TableField("build_type")
    private InterfaceBuildType buildType;
    @TableField("gray_ips")
    private String grayIps;
    @TableField("engine_type")
    private EngineType engineType;
    @TableField("exposed_by_restapi")
    private Boolean exposedByRestapi;
    @TableField("create_user")
    private String createUser;
    @TableField("update_user")
    private String updateUser;
    @TableField("create_time")
    private Timestamp createTime;
    @TableField("update_time")
    private Timestamp updateTime;

    public InterfaceData getInterfaceData() {
        if (interfaceData == null) {
            this.interfaceData = new InterfaceData();
        }
        return interfaceData;
    }
}
